<%--
  Created by IntelliJ IDEA.
  User: YSH
  Date: 2020/7/7
  Time: 20:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <%--主要功能:遍历所有学生信息--%>
    <title>主界面</title>
</head>
<body>
<table border="1" align="center" width="800px" cellpadding="0">
    <tr align="center">
        <td>编号</td>
        <td>姓名</td>
        <td>年龄</td>
        <td>地址</td>
    </tr>

    <c:forEach items="${pageInfo.list}" var="stu">
        <tr>
                <%--获取当前页所有学生信息--%>
            <td>${stu.id}</td>
            <td>${stu.name}</td>
            <td>${stu.age}</td>
            <td>${stu.address}</td>
        </tr>
    </c:forEach>


    <tr>
        <td colspan="4" align="center">
            <%--判断是否有上一页--%>
            <c:if test="${pageInfo.hasPreviousPage}">
                <a href="${pageContext.request.contextPath}/user?method=findAll&pageNum=${pageInfo.pageNum-1}">
                    上一页
                </a>
            </c:if>
            <%--页数展示--%>
            <span>
                    <c:forEach begin="1" end="${pageInfo.pages}" var="i">
                        <%-- 页码--%>
                        <a href="${pageContext.request.contextPath}/user?method=findAll&pageNum=${i}">${i}</a>
                    </c:forEach>
            </span>
                <%--是否是最后一页，是，显示包含内容，不是，不显示--%>
            <c:if test="${pageInfo.hasNextPage}">
                <a href="${pageContext.request.contextPath}/user?method=findAll&pageNum=${pageInfo.pageNum+1}">
                    下一页
                </a>
            </c:if>
            <br/>

            <span>总记录数：${pageInfo.total}</span>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <span>总页数：${pageInfo.pages}</span>


        </td>
    </tr>
</table>
</body>
</html>
